<template>
  <div>
      <a-row>
          <a-col :offset="1" @click="back">
            <a-button  @click="back"> <a-icon type="left" />退出查询</a-button>
          </a-col>
      </a-row>
     <a-row></a-row>
      <a-row>
          <a-col :offset="1">
               <a-table :columns="columns" :data-source="history">
                        <!-- <span slot="Idtitle"><a-icon type="solution" />测试结果Id</span> -->
                        <span slot="customTitle"><a-icon type="calendar" />时间</span>
                        <span slot="actionTitle"><a-icon type="file-search" />操作</span>
                        <span slot="action" slot-scope="text, record">
                        <a  @click="showDetail(record.test_id,record.time)"><a-icon type="search" />查看详情</a>
                        </span>
                </a-table>
          </a-col>
      </a-row>
  </div>
</template>

<script>
import {request} from '../../api'
export default {
    name:'Resultdisplay',
    data() {
        return {
            history:[],
            columns:[
            // {
               
            //     dataIndex: 'test_id',
            //     key: 'test_id',
            //     slots: { title: 'Idtitle' }
            // },
            {
                dataIndex:'time',
                key:'time',
                slots: { title: 'customTitle' },
            },
            {
                key: 'action',
                scopedSlots: { customRender: 'action' },
                slots:{title:'actionTitle'}
            }]
        }
    },
    // 返回路径设置为参数，以便老师查询学生测试页面使用该组件，提高复用性
    props:['stu_id','back_path'],
    created() {
        this.initData()
        this.$bus.$emit('hidden')
    },
    methods: {
        initData(){
            request({method:'post',url:'/SCLtest/SCL90_history',
            data:{id:this.stu_id,type:'scl'}}).then((res)=>{this.history=(res.data.history).reverse()})
        },
        showDetail(result_id,date){
            this.$router.push({path:'/SCLresult',query:{
                stu_id:this.stu_id,type:'scl',result_id:result_id,date:date}})
        },
        back(){
            this.$bus.$emit("show")
            // console.log(this.back_path)
            this.$router.replace(this.back_path)
            

            // this.$router.back();
        }
    },

}
</script>

<style lang="less" scoped>
.tab{
    text-align: center;
    font-size:20px;
    margin-left: 10px;
    margin-top:20px;

}
.tab tr td{
    padding:20px;
}
#title{
    background-color: #0072E3;
    color: white;
    padding:20px;
}
tr:hover{
    background-color: rgb(226, 223, 223);
}
h1{
    text-align: center;
    font-style: italic;
    color: #0084ff;
    width:900px;
}
th{
    text-align: center !important;
    
}
/deep/thead th{
   font-size: 16px;
   font-weight: bold;}

</style>